1. Field of the Invention
The present invention relates to the design of a graphical programming language interface. More specifically, the present invention relates to a method and an apparatus that refactors a graph structure expressed in a graphical programming language by inserting pass-through nodes into the graph.
2. Related Art
A graphical programming language (GPL) enables a programmer to interact with programs by graphically manipulating program components through a graphical user interface (GUI). Specifically, a program within a GPL is typically comprised of multiple base processing units, such as subroutines, or functions, and these base processing units are represented graphically as “boxes” or “patches” within the GUI. Each “patch” can have a number of input ports for receiving input variables/parameters, and a number of output ports for outputting results when the patch is executed. The relationships between patches can be understood by viewing their spatial arrangements and associated connectivity information within the GUI. This connectivity information is typically illustrated using lines, arrows, or arcs that connect the output ports of upstream patches to the input ports of downstream patches. The collection of the patches and the connections between the patches form a “graph” structure for a corresponding program.
During a graphical programming process, a programmer sometimes “refactors” a graph to improve the quality of the graph. The process of refactoring a program can be defined as “changing a software system in such a way that it does not alter the external behavior of the code, yet improves its internal structure.” (See M. Fowler, “Refactoring: Improving the Design of Existing Programs,” Addison-Wesley, 1999.) Within a GPL, a refactoring operation can be viewed as changing a graph to improve the topology of the graph while preserving the functional connectivity of the graph. Refactoring a graph can improve the graph's structure, making it easier to understand and modify, and allowing it to execute more efficiently.
One aspect of graph refactoring involves redistributing input and output variables in the graph to facilitate future extensions. In particular, it is often desirable to refactor the value on an input port of a patch to other input ports of other patches. Note that one can set a value on an input port by connecting an output port to the input port. However, it is generally prohibited to connect an input port directly to other input ports. Consequently, refactoring an input port associated with a desired value often requires a programmer to manually: (1) create a new patch in the graph; (2) set the value on the output port of the new patch to the desired input port value; (3) connect the output port of the new patch to the target input port; and (4) connect the output port of the new patch to other input ports that require the desired value. Unfortunately, this multi-step refactoring procedure is both tedious and error-prone.
Hence, what is needed is a method and a apparatus that can refactor an input port without the above-described problems.